package com.ck.core.constant.program;

/**
 * @author linqiang
 * @version v1.0
 * @Description 节目状态枚举
 * @date 2019-04-30 10:06
 */
public enum ProgramStatusEnum {
    TO_BE_PUBLISH("待发布", 1),
    TO_BE_APPROVAL("待审核", 2),
    TO_BE_PLAY("待播放", 3),
    PLAYING("播放中", 4),
    EXPIRED("已过期", 5),;

    private String name;
    private Integer value;

    public String getName() {
        return name;
    }

    public Integer getValue() {
        return value;
    }

    ProgramStatusEnum(String name, Integer value) {
        this.name = name;
        this.value = value;
    }

    /**
     * 根据值获取枚举类
     *
     * @param value 值
     * @return ProgramStatusEnum
     */
    public static ProgramStatusEnum getByValue(Integer value) {
        for (ProgramStatusEnum programStatusEnum : values()) {
            if (programStatusEnum.getValue().equals(value)) {
                return programStatusEnum;
            }
        }
        return null;
    }

    /**
     * 判断是否节目可发布
     *
     * @param value 节目当前状态
     * @return
     */
    public static boolean canPush(Integer value) {
        ProgramStatusEnum statusEnum = getByValue(value);
        return null != statusEnum && value.equals(TO_BE_PUBLISH.getValue());
    }
}
